//天空球是一个自发光材质的球体

#version 460
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec2 inUV;
layout (location = 2) in vec3 inWorldPos;
layout (location = 3) in float inCameraNearPlane;
layout (location = 4) in float inCameraFarPlane;

layout (location = 0) out vec4 outColor;

layout (set=0 ,binding = 0) uniform samplerCube TextureCubes[];

layout (set=2, binding = 0) uniform SceneBufferObject
{
    vec4 Floats[];

} SceneBuffer;

void main() 
{ 
    vec3 CameraWorldPos=SceneBuffer.Floats[13].xyz;

    vec3 Direction=normalize(inWorldPos-CameraWorldPos);

    //引擎坐标转换成opengl(不是vulkan)坐标系
    float temp=Direction.y;
    Direction.y=Direction.z;
    Direction.z=-temp;

    outColor=texture(TextureCubes[0],Direction);
}